package com.itheima.mapper;

import com.itheima.domain.pojo.Students;
import com.itheima.domain.pojo.StudentsQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface StudentsMapper {

    List<Students> list(StudentsQueryParam studentsQueryParam);

//    @Insert("insert into students(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id)" +
//            " values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId})")
    void add(Students students);

    void delete(List<Integer> id);

    //根据id查询学生
    @Select("select id,name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id from student where id=#{id}")
    Students getById(Integer id);

    //修改学生信息
    @Update("update student set name=#{name},no=#{no},gender=#{gender},phone=#{phone},id_card=#{idCard},is_college=#{isCollege},address=#{address},degree=#{degree},graduation_date=#{graduationDate},clazz_id=#{clazzId},update_time =#{updateTime} where id=#{id}")
    void update(Students students);

    @Update("update student set violation_count=violation_count+1,violation_score=violation_score+#{score},update_time = now() where id=#{id}")
    void violation(Integer id, Integer score);
}
